package com.taxshare.manager.controller;

import com.taxshare.manager.service.UserOrgService;
import com.taxshare.manager.view.dto.UserOrgDTO;
import com.taxshare.manager.view.dto.UserTaxNumberDTO;
import com.taxshare.response.beans.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: UserOrgController
 * @Description:
 * @author: luozhongyi
 * @date: 2021/2/4 14:27
 */
@RestController
@RequestMapping(value = "/userOrg")
@Api(tags = "用户组织信息")
public class UserOrgController {

    @Autowired
    UserOrgService userOrgService;

    @RequestMapping(method = RequestMethod.POST, value = "/init/LoginUserOrgs")
    @ApiOperation(notes = "用户信息", value = "初始化当前登录用户组织列表")
    public Response initLoginUserOrgs() {
        return userOrgService.initLoginUserOrgs();
    }

    /**
     * TODO 为什么前端会出现这两个接口《initLoginUseTaxNo》《initLoginUseTaxNos》
     * @return
     */
    @RequestMapping(method = RequestMethod.POST, value = "/init/initLoginUseTaxNo")
    @ApiOperation(notes = "用户信息", value = "初始化当前登录用户组织的税号列表")
    public Response initLoginUseTaxNo() {
        return userOrgService.initLoginUseTaxNos();
    }

    @RequestMapping(method = RequestMethod.POST, value = "/init/initLoginUseTaxNos")
    @ApiOperation(notes = "用户信息", value = "初始化当前登录用户组织的税号列表")
    public Response initLoginUseTaxNos() {
        return userOrgService.initLoginUseTaxNos();
    }


    @RequestMapping(method = RequestMethod.POST, value = "/save/taxNumber/list")
    @ApiOperation(notes = "用户信息", value = "保存关联税号")
    public Response saveTaxNumbers(@RequestBody UserOrgDTO userOrgDTO) {
        return userOrgService.saveTaxNumbers(userOrgDTO);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/get/org/list")
    @ApiOperation(notes = "用户信息", value = "用户已经绑定的税号")
    public Response getOrgs(@RequestBody UserOrgDTO userOrgDTO) {
        return userOrgService.getOrgs(userOrgDTO);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/init/UserAuthOrg")
    @ApiOperation(notes = "用户信息", value = "初始化当前登录用户不能操作的组织列表")
    public Response userAuthOrg(String userId) {
        return userOrgService.userAuthOrg(userId);
    }

}
